/*
 * Copyright (c)  2015~2020, xforceplus
 * All rights reserved.
 * Project:datacare-orm
 * Id: InsertBatchAnnotationMapperInvokeImpl.java   2020-10-10 11-01-55
 * Author: Evan
 */
package cn.datacare.orm.mapper.impl;

import cn.datacare.orm.manager.impl.SQLManager;
import cn.datacare.orm.mapper.MapperInvoke;

import java.lang.reflect.Method;
import java.util.List;

/**
 * <p>
 * Title:
 * </p>
 * <p>
 * Description:
 * </p>
 * <p>
 * Copyright: 2015~2020
 * </p>
 * <p>
 * Company/Department: xforceplus
 * </p>
 *
 * @author Evan
 * <b>Creation Time:</b> 2020-10-10 11-01-55
 * @since V1.0
 */
public class InsertBatchAnnotationMapperInvokeImpl implements MapperInvoke {
    /***
     * Mapper 调用
     * @param sqlManager
     * @param entityClass
     * @param sqlId
     * @param method
     * @param args
     * @return Object
     */
    @Override
    public Object call(SQLManager sqlManager, Class entityClass, String sqlId, Method method, Object[] args) {
        if (args.length == 1) {
            sqlManager.insertBatch(entityClass, (List) args[0]);
        } else {
            sqlManager.insertBatch(entityClass, (List) args[0], (Boolean) args[1]);
        }

        return null;
    }
}
